﻿using System.Diagnostics;

namespace JoelAbrahamsson.Web.Tests.UITests
{
    public class SeleniumServer
    {
        private static Process process;

        public static void Start()
        {
            if (IsStarted)
                return;

            IsStarted = true;

            process = new Process();
            process.StartInfo.FileName = JavaPath;
            process.StartInfo.Arguments = JavaArguments;
            process.StartInfo.CreateNoWindow = true;
            process.Start();
        }

        public static void Stop()
        {
            process.Kill();

            IsStarted = false;
        }

        public static bool IsStarted { get; set; }

        private static string JavaPath
        {
            get
            {
                return @"c:\Program Files (x86)\Java\jre6\bin\java.exe";
            }
        }

        private static string JavaArguments
        {
            get
            {
                return @"-jar c:\selenium-server-1.0.1\selenium-server.jar";
            }
        }
    }
}
